﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace Blitzcrank
{
    public static class Mouse
    {
        public static void LeftClick(IntPtr handle, int x, int y)
        {
            Cursor.Position = new Point(x, y);
            Win32.mouse_event(Win32.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
        }

        public static void LeftUnClick(IntPtr handle, int x, int y)
        {
            Cursor.Position = new Point(x, y);
            Win32.mouse_event(Win32.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
        }

        //const int WM_LBUTTONDOWN = 0x0201;
        //const int WM_LBUTTONUP = 0x0202;

        //private static IntPtr MakeLParam(int LoWord, int HiWord)
        //{
        //    return (IntPtr)((HiWord << 16) | (LoWord & 0xffff));
        //    //Int32 lParam = x + y * 0x00010000
        //    //return (IntPtr)(LoWord + HiWord * 0x00010000);
        //}

        //public static void leftClick(IntPtr handle, int x, int y)
        //{
        //    Win32.PostMessage(handle, WM_LBUTTONDOWN | WM_LBUTTONUP, IntPtr.Zero, MakeLParam(x, y));
        //}

        public static Point GetPosition()
        {
            Point position = new Point(Cursor.Position.X, Cursor.Position.Y);
            return position;
        }

        public static void SetPosition(int x, int y)
        {
            Cursor.Position = new Point(x, y);
        }
    }
}